/*
 * Preferences.java
 *
 * Copyright(c) 2010
 * Michael Kroez
 * kroez@studiorutton.de
 *
 * All rights reserved.
 *
 * $Id$
 * 
 */

package de.studiorutton.gerengdic;

import de.studiorutton.gerengdic.dictionary.DictionaryActivity;
import de.studiorutton.gerengdic.indexeddictionary.IndexedDictionaryActivity;
import android.preference.PreferenceActivity;
import android.content.Intent;
import android.os.Bundle;

public class Preferences extends PreferenceActivity {
	private final static String TAG = "learningwords";
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		addPreferencesFromResource(R.xml.preferences);
	}

	@Override
	protected void onPause() {
		// TODO Auto-generated method stub
		super.onPause();
//		Log.d(TAG, "PreferenceActivity:onStop" );
		Prefs prefs = Prefs.getInstance();
		prefs.setPreferences();

		if (prefs.viewConfigChanged()) {
//			Log.d( TAG, "PreferenceActivity:onStop viewConfigChanged = true" );
			LearningWordsActivity.ENABLE_RESTART = true;
			Intent i = new Intent(this, LearningWordsActivity.class);
			i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
					| Intent.FLAG_ACTIVITY_SINGLE_TOP);
			startActivity(i);
		}
		LearningWordsActivity.ENABLE_RESTART = false;
		
		if (prefs.searchConfigChanged()) {
			IndexedDictionaryActivity.RESTART_AUTOCOMPLETE = true;
			DictionaryActivity.RESTART_SEARCH = true;
		}
	}

}
